<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
namespace App\Service\Setting;

use App\Models\UserLevelSetting;
use App\Service\BaseService;

class UserSettingService extends BaseService
{
    /**
     * @param $level
     * @return null|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object
     */
    public function getUserLevelSetting($level = 1)
    {
        return UserLevelSetting::query()->where('level', $level)->first();
    }

    /**
     * @param $amount
     * @return null|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object
     */
    public function matchingLevel($amount)
    {
        $userLevelSettings = UserLevelSetting::query()
            ->whereBetween('amount', [0, $amount])
            ->orderByDesc('amount')
            ->get();
        return $userLevelSettings->first();
    }
}
